package bairui.international.console.web.controller.finance.withdraw;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.base.operate.OperateSupport;
import com.lianjing.sh.spring.web.controller.base.operate.OperateTarget;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;

import bairui.international.model.domain.jpa.TB_BranchCompanyWithdrawOrder;
import bairui.international.model.domain.jpa.TB_User;
import bairui.international.model.status.State_BranchCompanyWithdrawOrder;
import bairui.international.service.Service_BranchCompanyWithdrawOrder;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_Finance_Withdraw_Detail_DetailAccess 测试
 *
 */
@Controller
public class C_Finance_Withdraw_Detail_DetailAccess
 extends SC_Finance_Withdraw_Detail_DetailAccess 
{
	
	@Autowired private Service_BranchCompanyWithdrawOrder service_BranchCompanyWithdrawOrder;
	
	/**
	 * 访问详情页面
	 */
	@SuppressWarnings("serial")
	@Action(DetailAccess.class)
	@GetMapping(DetailAccess.RequestMappingValue)
	public ModelAndView detailAccess(
		ModelMap map, HttpServletRequest request,
		NavigationContext navigationContext, ModuleContext moduleContext, 
		@PathVariable(name=DetailAccess.PathVariableName.Id) long id
	) throws Exception {
		TB_BranchCompanyWithdrawOrder bean = service_BranchCompanyWithdrawOrder.findById(id);
		if(null != bean.getRemitImgUrl()){
			bean.setRemitImgUrl(C_Finance_Withdraw_ShowRemitImg_ShowImg.ShowImg.Operate(id).getUrl());
		}
		State_BranchCompanyWithdrawOrder State_BranchCompanyWithdrawOrder = bean.getState();
		/* 模块 */
		moduleContext
			.addModule(module_OrderInfo.module(
					new Module_OrderInfo_OutputModel(bean){
						private TB_User user;
						@Override protected void assign_before() {
							user = bean.getBranchCompanyStaff().getUser();
						}
						@Override protected String assignRealName() {
							return user.getRealName();
						}
						@Override protected String assignPhone() {
							return user.getPhone();
						}
						@Override protected String assignNickName() {
							return user.getNickName();
						}
						@Override protected String assignAvatarUrl() {
							return user.getAvatarUrl();
						}
					},
					new C_Finance_Withdraw_NoPass_AddAccess.AddAccess.Operate(){
						@Override public Object getId() { return id; }
						@Override public State_BranchCompanyWithdrawOrder getState_BranchCompanyWithdrawOrder() { return State_BranchCompanyWithdrawOrder; }
					}, 
					new C_Finance_Withdraw_Pass_Get.Get.Operate(){
						@Override public Object getId() { return id; }
						@Override public State_BranchCompanyWithdrawOrder getState_BranchCompanyWithdrawOrder() { return State_BranchCompanyWithdrawOrder; }
					}
				))
			.addModule(this.module_RemitImg.module(
					bean, 
					new C_Finance_Withdraw_Detail_Edit.Edit.Operate(){
						@Override public Object getId() { return id; }
						@Override public OperateTarget target() {
							return OperateTarget.Popup;
						}
						@Override public OperateSupport returnTo() {
							return new C_Finance_Withdraw_Detail_DetailAccess.DetailAccess.Operate() {
								@Override public Object getId() {
									return id;
								}
							};
						}
					}
				));
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
